/**
 * @param {string} digits
 * @return {string[]}
 */
var letterCombinations = function(digits) {
  const map = {
    '2': 'abc',
    '3': 'def',
    '4': 'ghi',
    '5': 'jkl',
    '6': 'mno',
    '7': 'pqrs',
    '8': 'tuv',
    '9': 'wxyz',
  }
  let path = []
  const ans = []
  const dfs = (currPos) => {
    if(currPos === digits.length) {
      ans.push(path.join(''))
      return
    }
      for(let j = 0; j < map[digits[currPos]].length; j++) {
        path.push(map[digits[currPos]][j])
        dfs(currPos + 1)
        path.pop()
      }
  }
  dfs(0)
  return ans
};
console.log(letterCombinations("23"));